package Day14_ArrayList;

//定义教师（Teacher）类，属性包含姓名和专业名称。将若干教师对象存入ArrayList集合中，并遍历集合打印教师信息

import java.util.ArrayList;

public class ZuoYe {
    public static void main(String[] args) {
        //创建集合
        ArrayList<Teacher> list = new ArrayList<>();
        //创建对象
        Teacher t1 = new Teacher("果果", "javase");
        Teacher t2 = new Teacher("张1", "javase");
        Teacher t3 = new Teacher("张2", "php");
        Teacher t4 = new Teacher("张3", "python");
        //添加到集合
        list.add(t1);
        list.add(t2);
        list.add(t3);
        list.add(t4);
        //遍历
        for (int i = 0; i < list.size(); i++) {
            //定义变量保存地址
            Teacher tt = list.get(i);
            //tt.getName
            //tt.getPro
            System.out.println("姓名:" + tt.getName() + "老师," + "专业:" + tt.getPro());
        }
    }
}

//定义Teacher类-----------------------------------------------------------------------------------------------------
class Teacher {
    private String name;
    private String pro;

    public Teacher() {
    }

    public Teacher(String name, String pro) {
        this.name = name;
        this.pro = pro;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPro() {
        return pro;
    }

    public void setPro(String pro) {
        this.pro = pro;
    }
}